#ifndef LOGIC_SORT_H
#define LOGIC_SORT_H

#include <iostream>
#include <string>
#include <vector>

#include "Parser.h"
#include "Data.h"
#include "Task.h"
#include "Writer.h"

#include <boost\date_time.hpp>

using namespace std;
using namespace boost::posix_time;
using namespace boost::gregorian;

class LogicSort {
public:
	string sortTasksAlphabetically(Parser::PARSED_COMMAND parsedCommand, 
										vector<Task>& tasksVector,
										Data* _data,
										Writer* _writer);

	string sortTasksByFlag(Parser::PARSED_COMMAND parsedCommand, 
										vector<Task>& tasksVector,
										Data* _data,
										Writer* _writer);

	string sortTasksByDateTime(Parser::PARSED_COMMAND parsedCommand, 
										vector<Task>& tasksVector,
										Data* _data,
										Writer* _writer);

	string sortTasksByDone(Parser::PARSED_COMMAND parsedCommand, 
										vector<Task>& tasksVector,
										Data* _data,
										Writer* _writer);

private:
	// sort by name : ascending
	bool sortAlpha(Task t1, Task t2);
	struct sortA {
		bool operator() (Task t1, Task t2) { return t1.getTaskName() < t2.getTaskName(); };
	} sortObjAlpha;

	// sort by date : ascending
	bool sortDateTime(Task t1, Task t2);
	struct sortT {
		bool operator() (Task t1, Task t2) { return t1.getStartDateTime() < t2.getStartDateTime(); };
	} sortObjDateTime;

	// sort by done|not done
	void sortByDone(vector<Task>& tasksVector);

	// sort by flagged|not flagged
	void sortByFlag(vector<Task>& tasksVector);

	static const string SORT_SUCCESS_MESSAGE;
	static const string SORT_INTERNAL_SUCCESS_MESSAGE;
	static const string SORT_ALPHA_SUCCESS_MESSAGE;
	static const string SORT_FLAG_SUCCESS_MESSAGE;
	static const string SORT_DATE_TIME_SUCCESS_MESSAGE;

	static const string SORT_ERROR_MESSAGE;
	static const string SORT_FLAG_ERROR_MESSAGE;
	static const string SORT_DATE_TIME_ERROR_MESSAGE;
	static const string SORT_DONE_ERROR_MESSAGE;

	static const string NOT_FOUND_ERROR_MESSAGE;
};
#endif